#lang R5RS

(define (atom? x)
  (not (or (pair? x) (null? x))))

(define (evens-only*&co l col)
  (cond
    ((null? l)
     (col '() 1 0))
    ((atom? (car l))
     (cond
       ((even? (car l))
        (evens-only*&co (cdr l)
                        (lambda (newl p s)
                          (col (cons (car l) newl)
                               (* p (car l))
                               s))))
       (else
         (evens-only*&co (cdr l)
                         (lambda (newl p s)
                           (col newl p (+ (car l) s)))))))
    (else
      (evens-only*&co (car l)
                      (lambda (al ap as)
                        (evens-only*&co (cdr l)
                                        (lambda (dl dp ds)
                                          (col (cons al dl)
                                               (* ap dp)
                                               (+ as ds)))))))))
